package com.zhoupeisen.controller;

import com.zhoupeisen.entity.Product;
import com.zhoupeisen.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName ProductController
 * @Description TODO
 * @Author Administrator
 * @Data 下午 03:22
 * @Version 1.0
 **/
@RestController
@RequestMapping("/product")
public class ProductController {
    @Autowired
    private ProductService productService;
    @RequestMapping(value = "/{id}",method = RequestMethod.GET)
    public Product findById(@PathVariable Long id) throws InterruptedException {
//    Thread.sleep(6000);
    Product product = productService.findById(id);
    return product;
}
    @RequestMapping(value = "",method = RequestMethod.POST)
    public String  findById(@RequestBody Product product){
        productService.save(product);
        return "保存成功";
    }

}
